package com.shihang.crm.bak;

import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import javax.imageio.ImageIO;

public class FileUtil {
	
	public static RGB getColor(String path,int x,int y){
		File file = new File(path);
		BufferedImage bi = null;
		try {
			bi = ImageIO.read(file);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new RGB(bi.getRGB(x, y));		
	}

    public static void readFile(String path, StrReceiver receiver) {
        try {
            FileReader reader = new FileReader(path);
            BufferedReader br = new BufferedReader(reader);
            String line;
            receiver.onStart();
            //�����Ƽ����Ӽ���д��
            while ((line = br.readLine()) != null) {
                // һ�ζ���һ������
                receiver.onStr(line);
            }
            receiver.onFinish();
        } catch (IOException e) {
            e.printStackTrace();
            receiver.onErr();
        }
    }
    
    public static interface StrReceiver {
        void onStart();
        void onStr(String str);
        void onFinish();
        void onErr();

    }
}
